const mysql = require('mysql')
const connection = mysql.createConnection({
  host: 'localhost',
  user: 'root',
  password: 'qqq123',
  port: '3306',
  database: 'test'
})
connection.connect();
const sql = "select * from stu where name=?";
const sqlParams = ["小明1"]

connection.query(sql, sqlParams, (err, result) => {
  if (err) {
    console.log(err);
    return
  }
  console.log(result)
  connection.destroy(); // 释放资源
})